<template>
  <div class="app-container">


    <div>
      <h2 style="color: #ed5565">全场通用以及指定分类优惠券</h2>
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="handleAdd"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="success"
              plain
              icon="Edit"
              :disabled="single"
              @click="handleUpdate"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="danger"
              plain
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="warning"
              plain
              icon="Download"
              @click="handleExport"
              v-hasPermi="['shop:coupon:export']"
          >导出</el-button>
        </el-col>
        <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>


      <el-table v-loading="loading" :data="couponList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="优惠券ID" align="center" prop="id" />
        <el-table-column label="优惠券类型" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.couponType == 0" style="margin-left: 10px">全场赠券</span>
              <span v-if="scope.row.couponType == 1" style="margin-left: 10px">会员赠券</span>
              <span v-if="scope.row.couponType == 2" style="margin-left: 10px">购物赠券</span>
              <span v-if="scope.row.couponType == 3" style="margin-left: 10px">注册赠券</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="优惠券图片" prop="couponImg" width="180">
          <template  #default="scope">
            <el-image :src="scope.row.couponImg" alt="图片损坏" width="50px" height="50px"></el-image>
          </template>
        </el-table-column>
        <el-table-column label="优惠券名称" align="center" prop="couponName" />
        <el-table-column label="数量" align="center" prop="num" />
        <el-table-column label="金额" align="center" prop="amount" />
        <el-table-column label="每人限领张数" align="center" prop="perLimit" />
        <el-table-column label="使用门槛" align="center" prop="minPoint" />
        <el-table-column label="开始时间" align="center" prop="startTime" />
        <el-table-column label="结束时间" align="center" prop="endTime" />
        <el-table-column label="备注" align="center" prop="note" />
        <el-table-column label="发行数量" align="center" prop="publishCount" />
        <el-table-column label="已使用数量" align="center" prop="useCount" />
        <el-table-column label="领取数量" align="center" prop="receiveCount" />
        <el-table-column label="可以领取的开始日期" align="center" prop="enableStartTime" />
        <el-table-column label="可以领取的结束日期" align="center" prop="enableEndTime" />
        <el-table-column label="优惠码" align="center" prop="code" />
        <el-table-column label="可以领取的会员等级" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.memberLevel == 0" style="margin-left: 10px">不限等级</span>
              <span v-if="scope.row.memberLevel == 1" style="margin-left: 10px">一级会员</span>
              <span v-if="scope.row.memberLevel == 2" style="margin-left: 10px">二级会员</span>
              <span v-if="scope.row.memberLevel == 3" style="margin-left: 10px">三级会员</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="优惠券使用类型" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.useType == 0" style="margin-left: 10px">全场通用</span>
              <span v-if="scope.row.useType == 1" style="margin-left: 10px">指定分类</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="发布状态" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.publish == 0" style="margin-left: 10px">未发布</span>
              <span v-if="scope.row.publish == 1" style="margin-left: 10px">已发布</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
            <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
            <el-button v-if="scope.row.publish == 0" link type="primary" icon="Delete" @click="updPublish(scope.row)">发布优惠券</el-button>
            <el-button v-if="scope.row.publish == 1" link type="primary" icon="Delete" @click="updStop(scope.row)">停发优惠券</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
          v-show="total>0"
          :total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
      />

      <!-- 添加或修改品牌对话框 -->
      <el-dialog :title="title" v-model="open" width="800px" append-to-body>
        <el-form ref="couponRef" :model="form" :rules="rules" label-width="150px">
          <el-form-item label="优惠券名称" prop="couponName">
            <el-input v-model="form.couponName" placeholder="请输入优惠券名称" />
          </el-form-item>
          <el-form-item label="优惠券类型" prop="couponType">
            <el-radio-group v-model="radio">
              <el-radio :value="0">全场赠券</el-radio>
              <el-radio :value="1">会员赠券</el-radio>
              <el-radio :value="2">购物赠券</el-radio>
              <el-radio :value="3">注册赠券</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="数量" prop="num">
            <el-input v-model="form.num" placeholder="请输入优惠券数量" />
          </el-form-item>
          <el-form-item label="金额" prop="amount">
            <el-input v-model="form.amount"  placeholder="请输入优惠券金额" />
          </el-form-item>
          <el-form-item label="每人限领张数" prop="perLimit">
            <el-input v-model="form.perLimit" placeholder="请输入限领张数" />
          </el-form-item>
          <el-form-item label="使用门槛" prop="minPoint">
            <el-input v-model="form.minPoint" placeholder="请输入使用门槛" />
          </el-form-item>
          <el-form-item label="发行数量" prop="publishCount">
            <el-input v-model="form.publishCount" placeholder="请输入发行数量" />
          </el-form-item>
          <el-form-item label="开始时间" prop="startTime">
            <el-input v-model="form.startTime" placeholder="请输入开始时间" />
          </el-form-item>
          <el-form-item label="结束时间" prop="endTime">
            <el-input v-model="form.endTime" placeholder="请输入结束时间" />
          </el-form-item>
          <el-form-item label="备注" prop="note">
            <el-input v-model="form.note" type="textarea" placeholder="备注" />
          </el-form-item>
          <el-form-item label="领取开始日期" prop="enableStartTime">
            <el-input v-model="form.enableStartTime" placeholder="请输入可以领取的开始日期" />
          </el-form-item>
          <el-form-item label="领取结束日期" prop="enableEndTime">
            <el-input v-model="form.enableEndTime" placeholder="请输入可以领取的结束日期" />
          </el-form-item>
          <el-form-item label="优惠码" prop="code">
            <el-input v-model="form.code" placeholder="请输入优惠码" />
          </el-form-item>
          <el-form-item label="领取的会员等级" prop="memberLevel">
            <el-radio-group v-model="form.memberLevel">
              <el-radio :value="0">不限等级</el-radio>
              <el-radio :value="1">一级会员</el-radio>
              <el-radio :value="2">二级会员</el-radio>
              <el-radio :value="3">三级会员</el-radio>
            </el-radio-group>
          </el-form-item>

          <el-form-item label="优惠券适用类型" prop="memberLevel">
            <el-radio-group v-model="form.useType">
              <el-radio :value="0">全场通用</el-radio>
              <el-radio :value="1">指定分类</el-radio>
            </el-radio-group>
          </el-form-item>


          <el-form-item label="优惠券图片" prop="couponImg">
            <img :src="form.couponImg" >
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </template>
      </el-dialog>
    </div>


    <div>
<h2 style="color: #ed5565">指定商品满减优惠券</h2>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="handleAdd1"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="success"
              plain
              icon="Edit"
              :disabled="single"
              @click="handleUpdate1"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="danger"
              plain
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete1"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="warning"
              plain
              icon="Download"
              @click="handleExport"
          >导出</el-button>
        </el-col>
        <right-toolbar v-model:showSearch="showSearch1" @queryTable="getFullList"></right-toolbar>
      </el-row>



      <el-table v-loading="loading1" :data="fullList" @selection-change="handleSelectionChange1">

        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="Id" align="center" prop="id" />
        <el-table-column label="商品Id" align="center" prop="skuId" />
        <el-table-column label="满多少" align="center" prop="fullPrice" />
        <el-table-column label="减多少" align="center" prop="reducePrice" />
        <el-table-column label="是否参与其他优惠券" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.addOther == 0" style="margin-left: 10px">不参与</span>
              <span v-if="scope.row.addOther == 1" style="margin-left: 10px">参与</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="primary" icon="Edit" @click="handleUpdate1(scope.row)">修改</el-button>
            <el-button link type="primary" icon="Delete" @click="handleDelete1(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
          v-show="total1>0"
          :total="total1"
          v-model:page="queryParams1.pageNum1"
          v-model:limit="queryParams1.pageSize1"
          @pagination="getFullList"
      />

      <!-- 添加或修改品牌对话框 -->
      <el-dialog :title="title1" v-model="open1" width="800px" append-to-body>
        <el-form ref="skuFullRef" :model="form1" :rules="rules1" label-width="150px">

          <el-form-item label="商品id" prop="skuId">
            <el-input v-model="form.skuId" placeholder="请输入商品id" />
          </el-form-item>

          <el-form-item label="满多少" prop="fullPrice">
            <el-input v-model="form.skuId" placeholder="请输入满多少" />
          </el-form-item>

          <el-form-item label="减多少" prop="reducePrice">
            <el-input v-model="form.skuId" placeholder="请输入减多少" />
          </el-form-item>

          <el-form-item label="是否参与其他优惠券" prop="addOther">
            <el-radio-group v-model="radio">
              <el-radio :value="0">不参与</el-radio>
              <el-radio :value="1">参与</el-radio>
            </el-radio-group>
          </el-form-item>

        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm1">确 定</el-button>
            <el-button @click="cancel1">取 消</el-button>
          </div>
        </template>
      </el-dialog>

    </div>




    <div>
      <h2 style="color: #ed5565"> 指定商品折扣优惠券</h2>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
              type="primary"
              plain
              icon="Plus"
              @click="handleAdd2"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="success"
              plain
              icon="Edit"
              :disabled="single"
              @click="handleUpdate2"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="danger"
              plain
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete2"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="warning"
              plain
              icon="Download"
              @click="handleExport"
          >导出</el-button>
        </el-col>
        <right-toolbar v-model:showSearch="showSearch2" @queryTable="getLadderList"></right-toolbar>
      </el-row>



      <el-table v-loading="loading2" :data="ladderList" @selection-change="handleSelectionChange2">

        <el-table-column type="selection" width="55" align="center" />

        <el-table-column label="Id" align="center" prop="id" />
        <el-table-column label="商品Id" align="center" prop="skuId" />
        <el-table-column label="满几件" align="center" prop="fullCount" />
        <el-table-column label="打几折" align="center" prop="discount" />
        <el-table-column label="是否参与其他优惠券" width="180">
          <template #default="scope">
            <div style="display: flex; align-items: center">
              <span v-if="scope.row.addOther == 0" style="margin-left: 10px">不参与</span>
              <span v-if="scope.row.addOther == 1" style="margin-left: 10px">参与</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-button link type="primary" icon="Edit" @click="handleUpdate2(scope.row)">修改</el-button>
            <el-button link type="primary" icon="Delete" @click="handleDelete2(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
          v-show="total2>0"
          :total="total2"
          v-model:page="queryParams2.pageNum2"
          v-model:limit="queryParams2.pageSize2"
          @pagination="getLadderList"
      />

      <!-- 添加或修改品牌对话框 -->
      <el-dialog :title="title2" v-model="open2" width="800px" append-to-body>
        <el-form ref="skuFullRef" :model="form2" :rules="rules2" label-width="150px">

          <el-form-item label="商品Id" prop="skuId">
            <el-input v-model="form.skuId" placeholder="请输入商品id" />
          </el-form-item>

          <el-form-item label="满几件" prop="fullCount">
            <el-input v-model="form.skuId" placeholder="请输入满几件" />
          </el-form-item>

          <el-form-item label="打几折" prop="discount">
            <el-input v-model="form.skuId" placeholder="请输入折扣" />
          </el-form-item>

          <el-form-item label="是否参与其他优惠券" prop="addOther">
            <el-radio-group v-model="radio">
              <el-radio :value="0">不参与</el-radio>
              <el-radio :value="1">参与</el-radio>
            </el-radio-group>
          </el-form-item>

        </el-form>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitForm2">确 定</el-button>
            <el-button @click="cancel2">取 消</el-button>
          </div>
        </template>
      </el-dialog>

    </div>






  </div>
</template>

<script setup name="coupon">
import {couponDelete, couponInsert, couponShow, couponUpdate, getCoupon} from "@/api/coupon/coupon.js";
import {
  getSkuFull,
  skuFullDelete,
  skuFullInsert,
  skuFullUpdateRule,
  skuIdFull
} from "../../../api/coupon/skuFullReduction.js";
import {
  getSkuLadder,
  skuIdLadder,
  skuLadderDelete,
  skuLadderInsert,
  skuLadderUpdateRule
} from "../../../api/coupon/skuLadder.js";
import {couponUpdPublish, couponUpdStop} from "../../../api/coupon/coupon.js";

const { proxy } = getCurrentInstance();

const couponList = ref([]);
const fullList = ref([]);
const ladderList = ref([]);
const open = ref(false);
const open1 = ref(false);
const open2 = ref(false);
const showSearch = ref(true);
const showSearch1 = ref(true);
const showSearch2 = ref(true);
const loading = ref(true);
const loading1 = ref(true);
const loading2 = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const total1 = ref(0);
const total2 = ref(0);
const title = ref("");
const title1 = ref("");
const title2 = ref("");


const data = reactive({
  form: {},
  form1: {},
  form2: {},
  queryParams: {
    pageNum: 1,
    pageSize: 3,
  },
  queryParams1: {
    pageNum1: 1,
    pageSize1: 3,
  },
  queryParams2: {
    pageNum2: 1,
    pageSize2: 3,
  },
  rules: {
  },
  rules1: {
  },
  rules2: {
  }
});
const radio = ref(0)
const { queryParams, form, rules ,form1 ,queryParams1,form2,queryParams2,rules1,rules2} = toRefs(data);

/** 查询通用优惠券列表 */
function getList() {
  couponShow(queryParams.value.pageNum, queryParams.value.pageSize).then(response => {
    console.log(response);
    if (Array.isArray(response.data)) {
      couponList.value = response.data.records;
      total.value = response.data.total;  // 假设这里是需要的总数
    } else {
      // 处理非数组类型的情况，例如直接赋值或者其他处理
      couponList.value = response.data.records;  // 假设数据在 response.data.coupons 中
      total.value = response.data.total;
    }
    loading.value = false;
  }).catch(error => {
    console.error('Error fetching coupon list:', error);
    loading.value = false;
  });
}


/** 查询商品专属满减优惠券列表 */
function getFullList() {
  skuIdFull(queryParams1.value.pageNum1, queryParams1.value.pageSize1).then(response => {
    console.log("满减",response);
    if (Array.isArray(response.data)) {
      fullList.value = response.data.records;
      total1.value = response.data.total;  // 假设这里是需要的总数
    } else {
      // 处理非数组类型的情况，例如直接赋值或者其他处理
      fullList.value = response.data.records;  // 假设数据在 response.data.coupons 中
      total1.value = response.data.total;
    }
    loading.value = false;
  }).catch(error => {
    console.error('Error fetching coupon list:', error);
    loading.value = false;
  });
}

/** 查询商品专属折扣优惠券列表 */
function getLadderList() {

  skuIdLadder(queryParams2.value.pageNum2, queryParams2.value.pageSize2).then(response => {
    console.log("折扣",response);
    if (Array.isArray(response.data)) {
      ladderList.value = response.data.records;
      total2.value = response.data.total;  // 假设这里是需要的总数
    } else {
      // 处理非数组类型的情况，例如直接赋值或者其他处理
      ladderList.value = response.data.records;  // 假设数据在 response.data.coupons 中
      total2.value = response.data.total;
    }
    loading.value = false;
  }).catch(error => {
    console.error('Error fetching coupon list:', error);
    loading.value = false;
  });
}



// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

function cancel1() {
  open1.value = false;
  reset1();
}

function cancel2() {
  open2.value = false;
  reset2();
}

// 全场表单重置
function reset() {
  form.value = {
    id : null,
    couponType : null,
    couponImg : null,
    couponName : null,
    num : null,
    amount : null,
    perLimit : null,
    minPoint : null,
    startTime : null,
    endTime : null,
    note : null,
    publishCount : null,
    useCount : null,
    receiveCount : null,
    enableStartTime : null,
    enableEndTime : null,
    code : null,
    memberLevel : null,
    publish : null,
    useType : null
  };
  proxy.resetForm("couponRef");
}

//满减
function reset1() {
  form1.value = {
    id : null,
    skuId : null,
    fullPrice : null,
    reducePrice : null,
    addOther : null
  };
  proxy.resetForm("fullRef");
}

//折扣
function reset2() {
  form2.value = {
    id : null,
    skuId : null,
    fullCount : null,
    discount : null,
    price : null,
    addOther : null
  };
  proxy.resetForm("ladderRef");
}

// 全场多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.brandId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

// 满减多选框选中数据
function handleSelectionChange1(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

// 折扣多选框选中数据
function handleSelectionChange2(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}


/** 全场新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加品牌";
}

/** 满减新增按钮操作 */
function handleAdd1() {
  reset();
  open1.value = true;
  title1.value = "添加品牌";
}

/** 折扣新增按钮操作 */
function handleAdd2() {
  reset();
  open2.value = true;
  title2.value = "添加品牌";
}

/** 全场修改按钮操作 */
function handleUpdate(row) {
  reset();
  const couponId = row.id || ids.value
  getCoupon(couponId).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改优惠券";
  });
}

/** 满减修改按钮操作 */
function handleUpdate1(row) {
  reset();
  const fullId = row.id || ids.value
  getSkuFull(fullId).then(response => {
    form1.value = response.data;
    open1.value = true;
    title1.value = "修改满减优惠券";
  });
}

/** 折扣修改按钮操作 */
function handleUpdate2(row) {
  reset();
  const ladderId = row.id || ids.value
  getSkuLadder(ladderId).then(response => {
    form2.value = response.data;
    open2.value = true;
    title2.value = "修改折扣优惠券";
  });
}

/** 全场提交按钮 */
function submitForm() {
  proxy.$refs["couponRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        couponUpdate(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        couponInsert(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 满减提交按钮 */
function submitForm1() {
  proxy.$refs["fullRef"].validate(valid => {
    if (valid) {
      if (form1.value.id != null) {
        skuFullUpdateRule(form1.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open1.value = false;
          getFullList();
        });
      } else {
        skuFullInsert(form1.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open1.value = false;
          getFullList();
        });
      }
    }
  });
}

/** 折扣提交按钮 */
function submitForm2() {
  proxy.$refs["brandRef"].validate(valid => {
    if (valid) {
      if (form2.value.id != null) {
        skuLadderUpdateRule(form2.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open2.value = false;
          getLadderList();
        });
      } else {
        skuLadderInsert(form2.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open2.value = false;
          getLadderList();
        });
      }
    }
  });
}

/** 通用删除按钮操作 */
function handleDelete(row) {
  const couponId = row.id || ids.value;
  proxy.$modal.confirm('是否确认删除优惠券编号为"' + couponId + '"的数据项？').then(function() {
    return couponDelete(couponId);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 满减删除按钮操作 */
function handleDelete1(row) {
  const fullId = row.id || ids.value;
  proxy.$modal.confirm('是否确认删除优惠券编号为"' + fullId + '"的数据项？').then(function() {
    return skuFullDelete(fullId);
  }).then(() => {
    getFullList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 折扣删除按钮操作 */
function handleDelete2(row) {
  const ladderId = row.id || ids.value;
  proxy.$modal.confirm('是否确认删除优惠券编号为"' + ladderId + '"的数据项？').then(function() {
    return skuLadderDelete(ladderId);
  }).then(() => {
    getLadderList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

//发布优惠券
function updPublish(row){
  const couponId = row.id || ids.value;
  proxy.$modal.confirm('是否确认发布优惠券编号为"' + couponId + '"的数据项？').then(function() {
    return couponUpdPublish(couponId);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("发布成功");
  }).catch(() => {});
}

//停止发放优惠券
function updStop(row){
  const couponId = row.id || ids.value;
  proxy.$modal.confirm('是否确认停发优惠券编号为"' + couponId + '"的数据项？').then(function() {
    return couponUpdStop(couponId);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("停发成功");
  }).catch(() => {});
}


function   handleExport() {
  proxy.download('shop/coupon/export', {
    ...queryParams.value
  }, `coupon_${new Date().getTime()}.xlsx`)
}


getList();
getLadderList();
getFullList();
</script>
